﻿/*系统自动生成的 sql server 版数据库操作类
* 开发时间：2010-4-29 15:05:05
* 版权所有：andy
* 其他联系：
* Email：yhailong@sina.com
* MSN：yhailong@hotmail.com
* QQ:9502855
* 声明：仅限于您自己使用，不得进行商业传播，违者必究！
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using EZCRS.HCMS.Entity;
using EZCRS.HCMS.Data;

namespace EZCRS.HCMS.SqlClient
{
    public class Sql_HCRS_CorpUser
    {
        private string SqlString = "";


        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="strColumn">查询的字段名,空则返回全部</param>
        /// <param name="currentPage"></param>
        /// <param name="strWhere">查询条件</param>
        /// <param name="orderBy">排序字段</param>
        /// <param name="pageCount">返回页数总数</param>
        /// <param name="recordCount">返回记录总数</param>
        /// <returns></returns>
        public List<HCRS_CorpUser> GetAllByPage(string strColumn,int currentPage, string strWhere,string orderBy,out int pageCount,out int recordCount)
        {
            pageCount = 1;
            List<HCRS_CorpUser> allLog = ExecSql.GetTableList<HCRS_CorpUser>("HCRS_CorpUser", strColumn, orderBy, "userid", CFun.pagesize(), currentPage, strWhere, out recordCount);
            pageCount = CFun.pagecount(recordCount);
            return allLog;
        }


        /// <summary>
        /// 返回所有符合条件的信息
        /// </summary>
        /// <param name="strWhere">查询条件</param>
        /// <param name="orderBy">排序规则</param>
        /// <returns></returns>
        public List<HCRS_CorpUser> GetAll(string strWhere,string orderBy)
        {
            if (strWhere != "")
                SqlString = "select * from HCRS_CorpUser where " + strWhere;
            else
                SqlString = "select * from HCRS_CorpUser ";
            if (orderBy != "")
                SqlString += " order by " + orderBy;
            try
            {
                return ExecSql.GetTableList<HCRS_CorpUser>(SqlString);
            }
            catch { return null; }
        }


        /// <summary>
        /// 返回一条信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public HCRS_CorpUser GetItem(int id)
        {
            try
            {
                return ExecSql.GetTableList<HCRS_CorpUser>("select * from HCRS_CorpUser where userid=" + id.ToString() + "")[0];
            }
            catch { return null; }
        }


        #region 删除
        /// <summary>
        /// 删除一条信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool DeleteItem(int id)
        {
            return (ExecSql.SqlExecNoquery("delete from HCRS_CorpUser where id=" + id.ToString()) > 0) ? true : false;
        }


        /// <summary>
        /// 删除一批数据
        /// </summary>
        /// <param name="idList"></param>
        /// <returns></returns>
        public bool DeleteItem(string idList)
        {
           
            return (ExecSql.SqlExecNoquery("delete from HCRS_CorpUser where id in ("+idList+")") > 0) ? true : false;
        }
        #endregion


        /// <summary>
        /// 新增或修改一条信息
        /// </summary>
        /// <param name="_HCRS_CorpUser"></param>
        /// <returns></returns>
        public bool InsertOrUpdate(HCRS_CorpUser _HCRS_CorpUser)
        {
            return ExecSql.InsertOrUpdateData<HCRS_CorpUser>(_HCRS_CorpUser);
        }



       #region DataSet 老方法 
       /// <summary>
       /// 分页查询
       /// </summary>
       /// <param name="Fields">查询的字段列</param>
       /// <param name="page">当前页数</param>
       /// <param name="StrWhere">查询条件</param>
       /// <param name="OrderBy">排序条件</param>
       /// <param name="KeyName">主键</param>
       /// <returns></returns>
       public DataSet GetAllByPage(string strColumn,int currentPage, string strWhere, string orderBy,string keyName)
       {
           return ExecSql.AddParamFrKeyField("HCRS_CorpUser", strColumn, orderBy, keyName, CFun.pagesize(), currentPage, strWhere);
       }


        /// <summary> 
        /// 获取指定内容 
        /// </summary> 
        /// <param name="Fields">指定字段</param> 
        /// <param name="StrWhere">条件</param> 
        /// <param name="OrderBy">排序规则</param> 
        /// <param name="Totals">记录条数，默认0=全部</param> 
        /// <returns></returns> 
        public DataTable GetAll(string strColumn, string strWhere, string orderBy,int totalRecord) 
        { 
            SqlString = "select "; 
            if (totalRecord > 0) 
                SqlString += " top "+totalRecord.ToString() ; 
            SqlString += " " + strColumn + " from HCRS_CorpUser "; 
            if (strWhere != "") 
                SqlString += " where "+strWhere; 
            if (orderBy != "") 
                SqlString += " order by "+orderBy; 
 
            return ExecSql.GetDataSet(SqlString).Tables[0]; 
        } 
        #endregion 



        #region 人工定义方法 by  

        #endregion 

    }
}
